﻿#-------------------------------------------------------------------------------
# Name:        OlsDdf
# Purpose:     From OlsDdf.h
#
# Author:      SUPER_紫电  QQ:911344755
#
# Created:     15/08/2022
# Copyright:   (c) SUPER_紫电 2022 All rights reserved.
# Licence:     <Modified BSD License>
#-------------------------------------------------------------------------------

#-----------------------------------------------------------------------------
#
# DLL Status Code
#
#-----------------------------------------------------------------------------

OLS_DLL_NO_ERROR                     = 0
OLS_DLL_UNSUPPORTED_PLATFORM         = 1
OLS_DLL_DRIVER_NOT_LOADED            = 2
OLS_DLL_DRIVER_NOT_FOUND             = 3
OLS_DLL_DRIVER_UNLOADED              = 4
OLS_DLL_DRIVER_NOT_LOADED_ON_NETWORK = 5
OLS_DLL_UNKNOWN_ERROR                = 9

#-----------------------------------------------------------------------------
#
# Driver Type
#
#-----------------------------------------------------------------------------

OLS_DRIVER_TYPE_UNKNOWN        = 0
OLS_DRIVER_TYPE_WIN_9X         = 1
OLS_DRIVER_TYPE_WIN_NT         = 2
OLS_DRIVER_TYPE_WIN_NT4        = 3    # Obsolete
OLS_DRIVER_TYPE_WIN_NT_X64     = 4
OLS_DRIVER_TYPE_WIN_NT_IA64    = 5    # Reseved

#-----------------------------------------------------------------------------
#
# PCI Error Code
#
#-----------------------------------------------------------------------------

OLS_ERROR_PCI_BUS_NOT_EXIST    = 0xE0000001
OLS_ERROR_PCI_NO_DEVICE        = 0xE0000002
OLS_ERROR_PCI_WRITE_CONFIG     = 0xE0000003
OLS_ERROR_PCI_READ_CONFIG      = 0xE0000004

#-----------------------------------------------------------------------------
#
# Support Macros
#
#-----------------------------------------------------------------------------

# Bus Number, Device Number and Function Number to PCI Device Address
def PciBusDevFunc(Bus, Dev, Func):
    return ((Bus & 0xFF) << 8) | ((Dev & 0x1F) << 3) | (Func & 7)
# PCI Device Address to Bus Number
def PciGetBus(address):
    return (address >> 8) & 0xFF
# PCI Device Address to Device Number
def PciGetDev(address):
    return (address >> 3) & 0x1F
# PCI Device Address to Function Number
def PciGetFunc(address):
    return address & 7
